package com.ktgj.train.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.train.domain.TrainPayNotifyrecord;
import com.ktgj.train.service.ITrainPayNotifyrecordService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 支付退款通知记录Controller
 * 
 * @author ruoyi
 * @date 2021-11-29
 */
@ControllerAdvice
@RestController
@RequestMapping("/notifyrecord")
public class TrainPayNotifyrecordController extends BaseController
{
    @Autowired
    private ITrainPayNotifyrecordService trainPayNotifyrecordService;

    /**
     * 查询支付退款通知记录列表
     */
    @PreAuthorize(hasPermi = "train:notifyrecord:list")
    @GetMapping("/list")
    public TableDataInfo list(TrainPayNotifyrecord trainPayNotifyrecord)
    {
        startPage();
        List<TrainPayNotifyrecord> list = trainPayNotifyrecordService.selectTrainPayNotifyrecordList(trainPayNotifyrecord);
        return getDataTable(list);
    }

    /**
     * 导出支付退款通知记录列表
     */
    @PreAuthorize(hasPermi = "train:notifyrecord:export")
    @Log(title = "支付退款通知记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TrainPayNotifyrecord trainPayNotifyrecord) throws IOException
    {
        List<TrainPayNotifyrecord> list = trainPayNotifyrecordService.selectTrainPayNotifyrecordList(trainPayNotifyrecord);
        ExcelUtil<TrainPayNotifyrecord> util = new ExcelUtil<TrainPayNotifyrecord>(TrainPayNotifyrecord.class);
        util.exportExcel(response, list, "支付退款通知记录数据");
    }

    /**
     * 获取支付退款通知记录详细信息
     */
    @PreAuthorize(hasPermi = "train:notifyrecord:query")
    @GetMapping(value = "/{notifyrecordid}")
    public AjaxResult getInfo(@PathVariable("notifyrecordid") Long notifyrecordid)
    {
        return AjaxResult.success(trainPayNotifyrecordService.selectTrainPayNotifyrecordById(notifyrecordid));
    }

    /**
     * 新增支付退款通知记录
     */
    @PreAuthorize(hasPermi = "train:notifyrecord:add")
    @Log(title = "支付退款通知记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TrainPayNotifyrecord trainPayNotifyrecord)
    {
        return toAjax(trainPayNotifyrecordService.insertTrainPayNotifyrecord(trainPayNotifyrecord));
    }

    /**
     * 修改支付退款通知记录
     */
    @PreAuthorize(hasPermi = "train:notifyrecord:edit")
    @Log(title = "支付退款通知记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TrainPayNotifyrecord trainPayNotifyrecord)
    {
        return toAjax(trainPayNotifyrecordService.updateTrainPayNotifyrecord(trainPayNotifyrecord));
    }

    /**
     * 删除支付退款通知记录
     */
    @PreAuthorize(hasPermi = "train:notifyrecord:remove")
    @Log(title = "支付退款通知记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{notifyrecordids}")
    public AjaxResult remove(@PathVariable Long[] notifyrecordids)
    {
        return toAjax(trainPayNotifyrecordService.deleteTrainPayNotifyrecordByIds(notifyrecordids));
    }
}
